#include "gbutton.h"



GAbstractButton::GAbstractButton(GUI *parent, DWORD dwType) : GUI(parent) {
	m_dwType = dwType;

	initGUI();
}


GAbstractButton::~GAbstractButton() {
	GUI::GUIManager.unregisterGUI(this);
}


void GAbstractButton::initGUI() {
	GRect geometry;
	geometry.x = CW_USEDEFAULT;
	geometry.y = CW_USEDEFAULT;
	geometry.width = 100;
	geometry.height = 24;

	createGUI(NULL, _T("Button"), getClassName(), WS_CHILD | WS_VISIBLE | WS_TABSTOP | m_dwType, &geometry, (HMENU)GUI::GUIManager.getGUICounter(), NULL);
	GUI::GUIManager.registerGUI(this);
}


bool GAbstractButton::isChecked() {
	return SendMessage(m_hWnd, BM_GETCHECK, 0, 0) == BST_CHECKED;
}


void GAbstractButton::setChecked(bool bChecked) {
	SendMessage(m_hWnd, BM_SETCHECK, (bChecked ? BST_CHECKED : BST_UNCHECKED), 0);
}
